<template>
	<view class="wrap">
		<view class="content">
			<u--form :model="license" ref="uForm" :labelStyle="{color: '#333', fontSize: '30rpx', fontWeight: '500'}">
				<view class="item">
					<view class="info-wrap" style="padding-top: 0;">
						<u-form-item label="是否牵引车" prop="typeTrailerValue" required labelWidth="200rpx" borderBottom
							@click="showTrailer = true">
							<u--input v-model="typeTrailerValue" placeholder="请选择" fontSize="30rpx" suffixIcon="arrow-right"
								suffixIconStyle="color: #c0c4cc" inputAlign="right" disabled disabledColor="#fff">
							</u--input>
						</u-form-item>
					</view>
					<view class="title" style="margin-top: 20rpx;">请上传行驶证</view>
					<view class="info-wrap">
						<view class="upload-box">
							<view class="upload-item">
								<u-upload :fileList="fileLicense" name="License" @afterRead="afterReadLicense"
									@delete="deletePic" :maxCount="1" width="320rpx" height="200rpx">
									<image src="@/static/bg_upload_1.png" style="width: 320rpx;height: 200rpx;">
									</image>
								</u-upload>
								<view class="desc">行驶证正页</view>
							</view>
							<view class="upload-item">
								<u-upload :fileList="fileLicenseDeputy" name="LicenseDeputy"
									@afterRead="afterReadLicenseDeputy" @delete="deletePic" :maxCount="1" width="320rpx"
									height="200rpx">
									<image src="@/static/bg_upload_2.png" style="width: 320rpx;height: 200rpx;">
									</image>
								</u-upload>
								<view class="desc">行驶证副页</view>
							</view>
						</view>
						<u-form-item label="车牌号" prop="plateNum" required labelWidth="200rpx" borderBottom
							@click="onPlate">
							<u-input v-model="license._plateNum" placeholder="请上传行驶证，系统自动识别" fontSize="30rpx"
								inputAlign="right" disabled disabledColor="#fff" />
						</u-form-item>
					</view>
				</view>
				
				<view class="item">
					<view class="title">请确定行驶证信息</view>
					<view class="info-wrap">
						<u-form-item label="车辆性质" prop="typeName" required labelWidth="200rpx" borderBottom
							@click="showType = true">
							<u--input v-model="typeName" placeholder="请选择" fontSize="30rpx" suffixIcon="arrow-right"
								suffixIconStyle="color: #c0c4cc" inputAlign="right" disabled disabledColor="#fff">
							</u--input>
						</u-form-item>
						<u-form-item label="车牌颜色" prop="colorName" required labelWidth="200rpx" borderBottom
							@click="showColor = true">
							<u--input v-model="colorName" placeholder="请选择" fontSize="30rpx" suffixIcon="arrow-right"
								suffixIconStyle="color: #c0c4cc" inputAlign="right" disabled disabledColor="#fff">
							</u--input>
						</u-form-item>
						<u-form-item label="强制报废期" prop="validPeriod" required labelWidth="200rpx" borderBottom
							@click="showValidPeriod = true">
							<u--input v-model="license.validPeriod" placeholder="请选择" fontSize="30rpx" suffixIcon="arrow-right"
								suffixIconStyle="color: #c0c4cc" inputAlign="right" disabled disabledColor="#fff">
							</u--input>
						</u-form-item>
						<u-form-item label="排放标准" prop="emissionStandardName" labelWidth="200rpx" borderBottom
							@click="showEmissionStandar = true">
							<u--input v-model="emissionStandardName" placeholder="请选择" fontSize="30rpx" suffixIcon="arrow-right"
								suffixIconStyle="color: #c0c4cc" inputAlign="right" disabled disabledColor="#fff">
							</u--input>
						</u-form-item>
					</view>
				</view>
				<view class="item">
					<view class="title">请上传道路运输证</view>
					<view class="info-wrap">
						<view class="upload-box">
							<view class="upload-item">
								<u-upload :fileList="fileRtc" name="Rtc" @afterRead="afterReadRtc" @delete="deletePic"
									:maxCount="1" width="320rpx" height="200rpx">
									<image src="@/static/bg_upload_1.png" style="width: 320rpx;height: 200rpx;">
									</image>
								</u-upload>
								<view class="desc">道路运输证正页</view>
							</view>
							<view class="upload-item">
								<u-upload :fileList="fileRtcDeputy" name="RtcDeputy" @afterRead="afterRead"
									@delete="deletePic" :maxCount="1" width="320rpx" height="200rpx">
									<image src="@/static/bg_upload_2.png" style="width: 320rpx;height: 200rpx;">
									</image>
								</u-upload>
								<view class="desc">道路运输证副页</view>
							</view>
						</view>
						<u-form-item label="道路运输证号" prop="rtcNo" :required="license.weightFlag" labelWidth="200rpx">
							<u-input v-model="license._rtcNo" type="number" placeholder="请上传行驶证，系统自动识别" fontSize="30rpx"
								inputAlign="right" />
						</u-form-item>
					</view>
				</view>
				
				<view class="item" style="display: none;">
					<view class="title">请上传本人有效从业资格证</view>
					<view class="info-wrap">
						<view class="upload-box">
							<view class="upload-item">
								<u-upload :fileList="fileTqc" name="Tqc" @afterRead="afterReadTqc" @delete="deletePic"
									:maxCount="1" width="320rpx" height="200rpx">
									<image src="@/static/bg_upload_1.png" style="width: 320rpx;height: 200rpx;">
									</image>
								</u-upload>
								<view class="desc">从业资格证正页</view>
							</view>
							<view class="upload-item">
								<u-upload :fileList="fileTqcDeputy" name="TqcDeputy" @afterRead="afterRead"
									@delete="deletePic" :maxCount="1" width="320rpx" height="200rpx">
									<image src="@/static/bg_upload_2.png" style="width: 320rpx;height: 200rpx;">
									</image>
								</u-upload>
								<view class="desc">从业资格证副页</view>
							</view>
						</view>
						<view class="tips">温馨提示：根据交通运输部关于网络货运的监督要求，我们需要您提供真实的身份信息进行司机身份的认证</view>
					</view>
				</view>
				<view class="item" v-show="typeTrailerValueCache == '1'">
					<view class="title">请上传挂车行驶证</view>
					<view class="info-wrap">
						<view class="upload-box">
							<view class="upload-item">
								<u-upload :fileList="filePictureImg" name="PictureImg" @afterRead="afterPictureImg"
									@delete="deletePic" :maxCount="1" width="320rpx" height="200rpx">
									<image src="@/static/bg_upload_1.png" style="width: 320rpx;height: 200rpx;">
									</image>
								</u-upload>
								<view class="desc">挂车行驶证正页</view>
							</view>
							<view class="upload-item">
								<u-upload :fileList="filePictureImgDeputy" name="PictureImgDeputy"
									@afterRead="afterPictureImgDeputy" @delete="deletePic" :maxCount="1" width="320rpx"
									height="200rpx">
									<image src="@/static/bg_upload_2.png" style="width: 320rpx;height: 200rpx;">
									</image>
								</u-upload>
								<view class="desc">挂车行驶证副页</view>
							</view>
						</view>
						<u-form-item label="车牌号" prop="plateNum" required labelWidth="200rpx" borderBottom
							@click="onPlate1">
							<u-input v-model="trailerInfo.plateNum" placeholder="请上传行驶证，系统自动识别" fontSize="30rpx"
								inputAlign="right" disabled disabledColor="#fff" />
						</u-form-item>
						<u-form-item label="强制报废期" prop="validPeriod" required labelWidth="200rpx" borderBottom
							@click="showValidPeriod1 = true">
							<u--input v-model="trailerInfo.validPeriod" placeholder="请选择" fontSize="30rpx" suffixIcon="arrow-right"
								suffixIconStyle="color: #c0c4cc" inputAlign="right" disabled disabledColor="#fff">
							</u--input>
						</u-form-item>
					</view>
				</view>
			</u--form>
		</view>
		<view class="bottom-wrap">
			<view class="submit" @click="submit">提交</view>
		</view>
		<plate-input v-if="showCar" :plate="license._plateNum" @export="setPlate" @close="showCar = false" />
		<plate-input v-if="showCar1" :plate="trailerInfo.plateNum" @export="setPlate1" @close="showCar1 = false" />
		<!-- 弹出层 -->
		<u-popup :show="showType" @close="typeCancel" :round="10">
			<view class="popup-wrap">
				<view class="title">选择车辆性质</view>
				<view class="popup-list">
					<view :class="typeColumns.length > 2 ? 'third' : 'second'">
						<text v-for="(item, index) in typeColumns" :key="index" @click="typeChange(item)"
							:class="{'active':typeNameCache == item.dicName}">{{item.dicName}}</text>
					</view>
				</view>
				<view class="popup-btn">
					<view class="cancel btn" @click="typeCancel">取消</view>
					<view class="confirm btn" @click="typeConfirm">确认</view>
				</view>
			</view>
		</u-popup>
		<u-popup :show="showEmissionStandar" @close="emissionCancel" :round="10">
			<view class="popup-wrap">
				<view class="title">选择车辆排放标准</view>
				<view class="popup-list">
					<view :class="typeEmission.length > 2 ? 'third' : 'second'">
						<text v-for="(item, index) in typeEmission" :key="index" @click="emissionChange(item)"
							:class="{'active':emissionStandardCache == item.dicName}">{{item.dicName}}</text>
					</view>
				</view>
				<view class="popup-btn">
					<view class="cancel btn" @click="emissionCancel">取消</view>
					<view class="confirm btn" @click="emissionConfirm">确认</view>
				</view>
			</view>
		</u-popup>
		<u-popup :show="showTrailer" @close="trailerCancel" :round="10">
			<view class="popup-wrap">
				<view class="title">是否牵引车</view>
				<view class="popup-list">
					<view :class="trailerColumns.length > 2 ? 'third' : 'second'">
						<text v-for="(item, index) in trailerColumns" :key="index" @click="trailerChange(item)"
							:class="{'active':typeTrailerNameCache == item.val}">{{item.dicName}}</text>
					</view>
				</view>
				<view class="popup-btn">
					<view class="cancel btn" @click="trailerCancel">取消</view>
					<view class="confirm btn" @click="trailerConfirm">确认</view>
				</view>
			</view>
		</u-popup>
		<u-popup :show="showColor" @close="colorCancel" :round="10">
			<view class="popup-wrap">
				<view class="title">选择车牌颜色</view>
				<view class="popup-list">
					<view :class="colorColumns.length > 2 ? 'third' : 'second'">
						<text v-for="(item, index) in colorColumns" :key="index" @click="colorChange(item)"
							:class="{'active':colorNameCache == item.dicName}">{{item.dicName}}</text>
					</view>
				</view>
				<view class="popup-btn">
					<view class="cancel btn" @click="colorCancel">取消</view>
					<view class="confirm btn" @click="colorConfirm">确认</view>
				</view>
			</view>
		</u-popup>
		<u-datetime-picker
			:show="showValidPeriod"
			v-model="validPeriod"
			:maxDate="time"
			mode="date"
			@confirm = "validPeriodConfirm"
			@cancel="showValidPeriod = false"
		></u-datetime-picker>
		<u-datetime-picker
			:show="showValidPeriod1"
			v-model="validPeriod1"
			:maxDate="time"
			mode="date"
			@confirm = "validPeriodConfirm1"
			@cancel="showValidPeriod1 = false"
		></u-datetime-picker>
		<u-modal :show="showModal" :content='contentModal' :closeOnClickOverlay="false" @confirm="confirm"
			@cancel="showModal = false" @close="showModal = false" confirmText="去申诉" :showCancelButton="true"></u-modal>
		<u-modal :show="showModal1" :content='contentModal1' :closeOnClickOverlay="false" @confirm="confirm1()"
			@cancel="cancel1()" @close="showModal1 = false" :showCancelButton="true"></u-modal>
	</view>
</template>

<script>
	import {
		queryDic,
		driverRelVehicle,
		vehicleInfo,
		editVehicle
	} from '@/config/api/app.js'
	import Cache from '@/utils/cache'
	import {
		formatDate
	} from '@/utils/tools'
	import plateInput from '@/components/uni-plate-input/uni-plate-input.vue'
	export default {
		data() {
			return {
				fileLicense: [],
				fileLicenseDeputy: [],
				fileRtc: [],
				fileRtcDeputy: [],
				fileTqc: [],
				fileTqcDeputy: [],
				filePictureImg:[], //挂车正面
				filePictureImgDeputy:[], //挂车反面
				license: {
					etpId: Cache.get("USERINFO")[0].etpId,
					plateNum: '',
					rtcNo: null,
				},
				validPeriod:null,//行驶证强制报废期
				validPeriodTime:'',
				showValidPeriod: false,
				validPeriod1:null,//挂车强制报废期
				validPeriodTime1:'',
				showValidPeriod1: false,
				showCar: false,
				showCar1: false,
				showType: false,
				showColor: false,
				showTrailer: false, //是否是挂车
				showEmissionStandar: false,//排放标准
				typeValue: '',
				typeValueCache: '', //	选择器缓存value
				typeName: '',
				typeNameCache: '', //	选择器缓存name
				colorValue: '',
				colorValueCache: '', //	选择器缓存value
				colorName: '',
				colorNameCache: '', //	选择器缓存name
				typeTrailerValue: '否',
				typeTrailerNameCache:'0',
				typeTrailerValueCache: 0,// 选择器缓存
				emissionStandardvalue: '',//排放标准
				emissionStandardName: '', //排放标准
				emissionStandardCache: '国六', //排放标准选择器缓存
				// #ifdef MP-WEIXIN
				typeColumns: null, // 解决动态绑定class失效问题 小程序设置null， app设置为空
				colorColumns: null,
				trailerColumns: [{'dicName':'是',val: 1},{'dicName':'否',val: 0}],
				// #endif
				// #ifdef APP-PLUS
				typeColumns: [],
				colorColumns: [],
				trailerColumns: [{'dicName':'是',val: 1},{'dicName':'否',val: 0}], //1是牵引车，0是非牵引车，2是挂车
				typeEmission:[{'dicName':'国六',val: 1},{'dicName':'国五',val: 2},{'dicName':'国四',val: 3},{'dicName':'国三',val: 4},{'dicName':'新能源',val: 5}],
				//1.国六 2.国五 3.国四  4.国三 5.新能源
				// #endif
				
				//先定义一下浏览器
				typeColumns: [],
				colorColumns: [],
				trailerColumns: [{'dicName':'是',val: 1},{'dicName':'否',val: 0}], //1是牵引车，0是非牵引车，2是挂车
				typeEmission:[{'dicName':'国六',val: 1},{'dicName':'国五',val: 2},{'dicName':'国四',val: 3},{'dicName':'国三',val: 4},{'dicName':'新能源',val: 5}],
				// end
				
				showModal: false,
				contentModal: '',
				vehicleId: '',
				type: '',
				trailerInfo:{
					plateNumOcr:'',
					pictureImgFlag: 0, //挂车图片是否异常 0.正常 1.异常
					pictureImgDeputyFlag: 0, //挂车副图片是否异常 0.正常 1.异常
				},
				time: null,
				showModal1: false, //挂车和行驶证照片不对照
				contentModal1:"",//展示内容
				showData: {},//暂存的信息
			}
		},
		created() {
			this.getQueryDic()
		},
		async onLoad(options) {
			
			if (options.id) {
				this.vehicleId = options.id
				this.type = 1 // 1是编辑
				await this.getEditDetail(this.vehicleId)
			}
		},
		mounted() {
			this.getQueryDic()
			this.time = this.GetYear(100)
		},
		methods: {
			GetYear(year) {
				var time = new Date();
			    time.setFullYear(time.getFullYear() + year);
			    var y = time.getFullYear();
			    var m = time.getMonth() + 1;
			    var d = time.getDate();
			
			    return Date.parse(y + "-" + m + '-' + d) ;
			},
			//挂车信息弹框
			confirm1(){
				if(this.showData.dataType == 1){
					this.fileLicense = this.filePictureImg 
					this.filePictureImg = []
					this.fileLicense.splice(0, 1, Object.assign(this.fileLicense[0], {
						status: 'success',
						message: '上传成功',
						url: this.showData.imgurl
					}))
					this.license.drivingLicense = this.showData.imgurl;
					this.license.natureUse = this.showData.natureUse;
					this.license._plateNum = this.showData.plateNum;
					this.license.plateNum = this.showData.plateNum;
					this.license.vehicleBrand = this.showData.vehicleBrand;
					this.license.registerDate = formatDate(this.showData.registerDate);
					this.license.vin = this.showData.vin;
					this.license.issueDate = formatDate(this.showData.issueDate);
					this.license.owner = this.showData.owner;
					this.license.issuingOrganizations = this.showData.issuingOrganizations;
					this.license.area =this.showData.area;
					this.license.type = this.showData.type;
					this.license.validPeriod = this.showData.validPeriod
					this.license.uploadDrivingLicenseFlag = this.showData.uploadDrivingLicenseFlag;
					this.license.uploadDrivingLicenseMsg = this.showData.uploadDrivingLicenseMsg;
					this.license.typeTrailerValue = this.showData.isTractor==1?'是':'否'; 
					this.license.isTractorOrc = this.showData.isTractor
					this.showModal1 = false
				}else if(this.showData.dataType == 2){
					
					this.filePictureImg = this.fileLicense
					this.fileLicense = []
					this.filePictureImg.splice(0, 1, Object.assign(this.filePictureImg[0], {
						status: 'success',
						message: '上传成功',
						url: this.showData.imgurl
					}))
					this.trailerInfo.pictureImg = this.showData.imgurl
					// this.trailerInfo.isTractorOrc = this.showData.isTractorOrc
					this.trailerInfo.plateNum = this.showData.plateNum
					this.trailerInfo.plateNumOcr = this.showData.plateNum
					this.trailerInfo.vehicleColour = this.showData.vehicleColour
					this.trailerInfo.vanType = this.showData.vanType
					this.trailerInfo.validPeriod = this.showData.validPeriod
					this.trailerInfo.axle = this.showData.axle
					this.trailerInfo.length =this.showData.length
					this.trailerInfo.width = this.showData.width
					this.trailerInfo.high = this.showData.high
					this.trailerInfo.natureUse = this.showData.natureUse
					this.trailerInfo.owner = this.showData.owner
					this.trailerInfo.vehicleEnergyType = this.showData.vehicleEnergyType
					this.trailerInfo.issuingOrganizations = this.showData.issuingOrganizations
					this.trailerInfo.registerDate = this.showData.registerDate
					this.trailerInfo.vin = this.showData.vin
					this.trailerInfo.vehicleBrand = this.showData.vehicleBrand
					this.trailerInfo.fileNo =this.showData.fileNo?this.showData.fileNo:''
					this.trailerInfo.issueDate = this.showData.issueDate
					this.trailerInfo.pictureImgFlag = '0'
					this.trailerInfo.pictureImgDeputyFlag = '0'
					this.trailerInfo.isTractorOrc = this.showData.isTractor
					this.showModal1 = false
					this.typeTrailerValue = '是'
					this.typeTrailerValueCache = 1
				}
			},
			cancel1(){
				//行驶证照片不对仍要上传
				 console.log(this.showData.dataType,'0.非牵引车 1.牵引车 2.挂车')//1的时候是牵引车，2的时候是挂车
				if(this.showData.dataType == 1){
					//1的时候是牵引车，2的时候是挂车
					// this.filePictureImg = this.fileLicense
					// this.fileLicense = []
					// this.filePictureImg.splice(0, 1, Object.assign(this.filePictureImg[0], {
					// 	status: 'success',
					// 	message: '上传成功',
					// 	url: this.showData.imgurl
					// }))
					this.filePictureImg = [{
						url: this.showData.imgurl
					}]
					this.trailerInfo.pictureImg = this.showData.imgurl
					this.trailerInfo.isTractorOrc = this.showData.isTractorOrc
					this.trailerInfo.plateNum = this.showData.plateNum
					this.trailerInfo.plateNumOcr = this.showData.plateNum
					this.trailerInfo.vehicleColour = this.showData.vehicleColour
					this.trailerInfo.vanType = this.showData.vanType
					this.trailerInfo.validPeriod = this.showData.validPeriod
					this.trailerInfo.axle = this.showData.axle
					this.trailerInfo.length =this.showData.length
					this.trailerInfo.width = this.showData.width
					this.trailerInfo.high = this.showData.high
					this.trailerInfo.natureUse = this.showData.natureUse
					this.trailerInfo.owner = this.showData.owner
					this.trailerInfo.vehicleEnergyType = this.showData.vehicleEnergyType
					this.trailerInfo.issuingOrganizations = this.showData.issuingOrganizations
					this.trailerInfo.registerDate = this.showData.registerDate
					this.trailerInfo.vin = this.showData.vin
					this.trailerInfo.vehicleBrand = this.showData.vehicleBrand
					this.trailerInfo.fileNo =this.showData.fileNo?this.showData.fileNo:''
					this.trailerInfo.issueDate = this.showData.issueDate
					this.trailerInfo.isTractorOrc = this.showData.isTractor
					this.trailerInfo.pictureImgFlag = '0'
					this.trailerInfo.pictureImgDeputyFlag = '0'
					this.showModal1 = false
				}else if(this.showData.dataType == 2){
					// this.filePictureImg = this.fileLicense
					// this.filePictureImg = []
					// this.fileLicense.splice(0, 1, Object.assign(this.fileLicense[0], {
					// 	status: 'success',
					// 	message: '上传成功',
					// 	url: this.showData.imgurl
					// }))
					this.fileLicense = [{
						url: this.showData.imgurl
					}]
					console.log(this.trailerInfo,333333)
					this.license.drivingLicense = this.showData.imgurl;
					this.license.natureUse = this.showData.natureUse;
					this.license._plateNum = this.showData.plateNum;
					this.license.plateNum = this.showData.plateNum;
					this.license.vehicleBrand = this.showData.vehicleBrand;
					this.license.registerDate = formatDate(this.showData.registerDate);
					this.license.vin = this.showData.vin;
					this.license.issueDate = formatDate(this.showData.issueDate);
					this.license.owner = this.showData.owner;
					this.license.issuingOrganizations = this.showData.issuingOrganizations;
					this.license.area =this.showData.area;
					this.license.type = this.showData.type;
					this.license.validPeriod = this.showData.validPeriod
					this.license.uploadDrivingLicenseFlag = this.showData.uploadDrivingLicenseFlag;
					this.license.uploadDrivingLicenseMsg = this.showData.uploadDrivingLicenseMsg;
					this.license.typeTrailerValue = this.showData.isTractor==1?'是':'否'; 
					this.license.isTractorOrc = this.showData.isTractor
					console.log(this.trailerInfo,222222222)
					this.showModal1 = false
				}
			},
			//	车辆信息
			getEditDetail(id) {
				let params = {
					vehicleId: id
				}
				vehicleInfo({
					params: params,
					custom: {
						title: '信息获取中……'
					}
				}).then((res) => {
					if (res.code == 0) {
						console.log(res.data,'编辑详情11111')
						let vehicleInfo = res.data.vehicleInfo

						this.fileLicense = [{
							url: vehicleInfo.drivingLicense
						}]
						this.fileLicenseDeputy = [{
							url: vehicleInfo.vehicleLicenseDeputy
						}]
						if (vehicleInfo.rtc) {
							this.fileRtc = [{
								url: vehicleInfo.rtc
							}]
						}
						if (vehicleInfo.rtcDeputy) {
							this.fileRtcDeputy = [{
								url: vehicleInfo.rtcDeputy
							}]
						}
						this.colorValue = vehicleInfo.plateColour
						this.typeValue = vehicleInfo.vehicleNature
						this.colorName = this.colorColumns[this.colorValue - 1].dicName
						this.typeName = this.typeColumns[this.typeValue - 1].dicName
						this.typeNameCache = this.typeName
						this.colorNameCache = this.colorName

						this.license.drivingLicense = vehicleInfo.drivingLicense;
						this.license.natureUse = vehicleInfo.natureUse;
						this.license._plateNum = vehicleInfo.manualPlateNum;
						this.license.plateNum = vehicleInfo.plateNum;
						this.license.vehicleBrand = vehicleInfo.vehicleBrand;
						this.license.registerDate = formatDate(vehicleInfo.registerDate);
						this.license.vin = vehicleInfo.vin;
						this.license.issueDate = formatDate(vehicleInfo.issueDate);
						this.license.owner = vehicleInfo.owner;
						this.license.issuingOrganizations = vehicleInfo.issuingOrganizations;
						this.license.area = vehicleInfo.area;
						this.license.type = vehicleInfo.type;
						this.license.uploadDrivingLicenseFlag = vehicleInfo.uploadDrivingLicenseFlag ? vehicleInfo.uploadDrivingLicenseFlag : 0
						this.license.uploadDrivingLicenseMsg = vehicleInfo.uploadDrivingLicenseMsg ? vehicleInfo.uploadDrivingLicenseMsg : ''
						// this.license._rtcNo =  vehicleInfo.rtcNo;
						this.license.vehicleLicenseDeputy = vehicleInfo.vehicleLicenseDeputy;
						this.license.plateNumOcrDrivingPermit = vehicleInfo.plateNumOcrDrivingPermit;
						this.license.tonnage = vehicleInfo.tonnage;
						this.license.approvedLoad = vehicleInfo.approvedLoad;
						this.license.length = vehicleInfo.length;
						this.license.width = vehicleInfo.width;
						this.license.high = vehicleInfo.high;
						this.license.validPeriod = formatDate(vehicleInfo.validPeriod);
						this.license.vehicleEnergyType = vehicleInfo.vehicleEnergyType;
						this.license.curbWeight = vehicleInfo.curbWeight;
						this.license.quasiTraction = vehicleInfo.quasiTraction;
						this.license.fileNo = vehicleInfo.fileNo;
						this.license.weightFlag = vehicleInfo.weightFlag;
						this.license.tqcFlag = vehicleInfo.tqcFlag;
						this.license.uploadDrivingLicenseDeputyFlag = vehicleInfo.uploadDrivingLicenseDeputyFlag ? vehicleInfo.uploadDrivingLicenseDeputyFlag : 0
						this.license.uploadDrivingLicenseDeputyMsg = vehicleInfo.uploadDrivingLicenseDeputyMsg ? vehicleInfo.uploadDrivingLicenseDeputyMsg : ''

						this.license.rtc = vehicleInfo.rtc;
						this.license._rtcNo = vehicleInfo.manualRtcNo?vehicleInfo.manualRtcNo:vehicleInfo.rtcNo;
						this.license.rtcNo = vehicleInfo.rtcNo;
						this.license.uploadRtcFlag = vehicleInfo.uploadRtcFlag ? vehicleInfo.uploadRtcFlag : 0
						this.license.uploadRtcMsg = vehicleInfo.uploadRtcMsg ? ehicleInfo.uploadRtcMsg : ''
						this.license.typeTrailerValue = vehicleInfo.isTractor == 1?'是':'否'; 
						this.license.typeTrailerValueCache = vehicleInfo.isTractor;
						this.typeTrailerValue = vehicleInfo.isTractor == 1?'是':'否';
						this.typeTrailerValueCache = vehicleInfo.isTractor;
						this.license.isTractor = vehicleInfo.isTractor
						this.emissionStandardvalue = vehicleInfo.emissionStandard
						this.license.emissionStandard = vehicleInfo.emissionStandard
						this.emissionStandardName = this.typeEmission[vehicleInfo.emissionStandard-1].dicName
						//挂车信息
						this.trailerInfo.pictureImg = vehicleInfo.trailerInfo.pictureImg ? vehicleInfo.trailerInfo.pictureImg : ''
						this.trailerInfo.pictureImgDeputy = vehicleInfo.trailerInfo.pictureImgDeputy ? vehicleInfo.trailerInfo.pictureImgDeputy : ''
						this.trailerInfo.plateNum = vehicleInfo.trailerInfo.plateNum
						this.trailerInfo.plateNumOcr = vehicleInfo.trailerInfo.plateNumOcr
						this.trailerInfo.vehicleColour = vehicleInfo.trailerInfo.vehicleColour
						this.trailerInfo.vanType = vehicleInfo.trailerInfo.vanType
						this.trailerInfo.validPeriod = vehicleInfo.trailerInfo.validPeriod
						this.trailerInfo.axle = vehicleInfo.trailerInfo.axle
						this.trailerInfo.length = vehicleInfo.trailerInfo.length
						this.trailerInfo.width = vehicleInfo.trailerInfo.width
						this.trailerInfo.high = vehicleInfo.trailerInfo.high
						this.trailerInfo.natureUse = vehicleInfo.trailerInfo.natureUse
						this.trailerInfo.owner = vehicleInfo.trailerInfo.owner
						this.trailerInfo.vehicleEnergyType = vehicleInfo.trailerInfo.vehicleEnergyType
						this.trailerInfo.issuingOrganizations = vehicleInfo.trailerInfo.issuingOrganizations
						this.trailerInfo.registerDate = vehicleInfo.trailerInfo.registerDate
						this.trailerInfo.vin = vehicleInfo.trailerInfo.vin
						this.trailerInfo.vehicleBrand = vehicleInfo.trailerInfo.vehicleBrand
						this.trailerInfo.fileNo = vehicleInfo.trailerInfo.fileNo
						this.trailerInfo.issueDate = vehicleInfo.trailerInfo.issueDate
						this.trailerInfo.isTractorOrc =vehicleInfo.trailerInfo.isTractor
						
						this.filePictureImg = [{
							url: vehicleInfo.trailerInfo.pictureImg
						}]
						this.filePictureImgDeputy = [{
							url: vehicleInfo.trailerInfo.pictureImgDeputy
						}]
					} else {
						uni.$u.toast(res.msg);
					}
				}).catch(err => {
					console.log(err)
				})
			},
			// 删除图片
			deletePic(event) {
				this[`file${event.name}`].splice(event.index, 1)
				if (!this.fileLicense.length) {
					this.license.drivingLicense = ''
					this.license.natureUse = ''
					this.license._plateNum = ''
					this.license.plateNum = ''
					this.license.vehicleBrand = ''
					this.license.registerDate = ''
					this.license.vin = ''
					this.license.issueDate = ''
					this.license.owner = ''
					this.license.issuingOrganizations = ''
					this.license.area = ''
					this.license.type = ''
					this.license.uploadDrivingLicenseFlag = ''
					this.license.uploadDrivingLicenseMsg = ''
				}
				if (!this.fileLicenseDeputy.length) {
					this.license.vehicleLicenseDeputy = ''
					this.license.plateNumOcrDrivingPermit = ''
					this.license.tonnage = ''
					this.license.approvedLoad = ''
					this.license.length = ''
					this.license.width = ''
					this.license.high = ''
					this.license.validPeriod = ''
					this.license.vehicleEnergyType = ''
					this.license.curbWeight = ''
					this.license.quasiTraction = ''
					this.license.fileNo = ''
					this.license.weightFlag = ''
					this.license.tqcFlag = ''
					this.license.uploadDrivingLicenseDeputyFlag = ''
					this.license.uploadDrivingLicenseDeputyMsg = ''
				}
				if (!this.fileRtc.length) {
					this.license.rtc = ''
					this.license._rtcNo = ''
					this.license.rtcNo = ''
					this.license.uploadRtcFlag = ''
					this.license.uploadRtcMsg = ''
				}
				if (!this.fileTqc.length) {
					this.license.tqc = ''
					this.license.tqcNo = ''
				}
				if (!this.filePictureImg.length) {
					this.trailerInfo.pictureImg = ''
					this.trailerInfo.plateNum = ''
					this.trailerInfo.plateNumOcr = ''
					this.trailerInfo.vehicleColour = ''
					this.trailerInfo.vanType = ''
					this.trailerInfo.axle = ''
					this.trailerInfo.natureUse = ''
					this.trailerInfo.owner = ''
					this.trailerInfo.vehicleEnergyType = ''
					this.trailerInfo.issuingOrganizations =''
					this.trailerInfo.registerDate = ''
					this.trailerInfo.vin = ''
					this.trailerInfo.vehicleBrand = ''
					this.trailerInfo.fileNo = ''
					this.trailerInfo.issueDate = ''
					this.trailerInfo.isTractorOrc = ''
				}
				if (!this.filePictureImgDeputy.length) {
					this.trailerInfo.pictureImgDeputy = ''
					this.trailerInfo.plateNumDeputyOcr = ''
					this.trailerInfo.validPeriod = ''
					this.trailerInfo.validPeriodOcr = ''
					this.trailerInfo.length = ''
					this.trailerInfo.width = ''
					this.trailerInfo.high = ''
				}
			},
			// 行驶证正面
			async afterReadLicense(event) {
				let api = `${this.baseUrl}/driverService/upload_driving_license`
				let lists = [].concat(event.file)
				this[`file${event.name}`].push({
					...event.file,
					status: 'uploading',
					message: '上传中'
				})
				console.log(this.fileLicense)
				const result = await this.uploadFilePromise(lists[0].thumb, api)
				const res = JSON.parse(result)
				console.log(res,'行驶证正面数据')
				if (res.code != 0) {
					uni.$u.toast(res.msg)
					this[`file${event.name}`] = []
				} else {
					this.showData = res.data
					if(res.data.isTractor == '2'){
						this.showModal1 = true
						this.contentModal1 = '系统检测到该证件为挂车行驶证，请问是否切换到挂车证件上传'
						this.showData.dataType = 2
						return false
					}
					this[`file${event.name}`].splice(0, 1, Object.assign(this[`file${event.name}`][0], {
						status: 'success',
						message: '上传成功',
						url: res.data.imgurl
					}))
					this.license.drivingLicense = res.data.imgurl;
					this.license.natureUse = res.data.natureUse;
					this.license._plateNum = res.data.plateNum;
					this.license.plateNum = res.data.plateNum;
					this.license.vehicleBrand = res.data.vehicleBrand;
					this.license.registerDate = formatDate(res.data.registerDate);
					this.license.vin = res.data.vin;
					this.license.issueDate = formatDate(res.data.issueDate);
					this.license.owner = res.data.owner;
					this.license.issuingOrganizations = res.data.issuingOrganizations;
					this.license.area = res.data.area;
					this.license.type = res.data.type;
					this.license.uploadDrivingLicenseFlag = res.data.uploadDrivingLicenseFlag;
					this.license.uploadDrivingLicenseMsg = res.data.uploadDrivingLicenseMsg;
					this.typeTrailerValue = res.data.isTractor==1?'是':'否'; 
					this.license.isTractorOrc = res.data.isTractor
					this.typeTrailerValueCache = res.data.isTractor == 0?0:1; 
				}
			},
			// 行驶证反面
			async afterReadLicenseDeputy(event) {
				let api = `${this.baseUrl}/driverService/upload_driving_license_deputy`
				let lists = [].concat(event.file)
				this[`file${event.name}`].push({
					...event.file,
					status: 'uploading',
					message: '上传中'
				})
				const result = await this.uploadFilePromise(lists[0].thumb, api)
				const res = JSON.parse(result)
				console.log(res)
				if (res.code != 0) {
					uni.$u.toast(res.msg)
					this[`file${event.name}`] = []
				} else {
					this[`file${event.name}`].splice(0, 1, Object.assign(this[`file${event.name}`][0], {
						status: 'success',
						message: '上传成功',
						url: res.data.imgurl
					}))
					this.license.vehicleLicenseDeputy = res.data.imgurl;
					this.license.plateNumOcrDrivingPermit = res.data.plateNumOcrDrivingPermit;
					this.license.tonnage = res.data.tonnage;
					this.license.approvedLoad = res.data.approvedLoad;
					this.license.length = res.data.length;
					this.license.width = res.data.width;
					this.license.high = res.data.high;
					this.license.validPeriod = formatDate(res.data.validPeriod);
					this.license.vehicleEnergyType = res.data.vehicleEnergyType;
					this.license.curbWeight = res.data.curbWeight;
					this.license.quasiTraction = res.data.quasiTraction;
					this.license.fileNo = res.data.fileNo;
					this.license.weightFlag = res.data.weightFlag;
					this.license.tqcFlag = res.data.tqcFlag;
					this.license.uploadDrivingLicenseDeputyFlag = res.data.uploadDrivingLicenseDeputyFlag;
					this.license.uploadDrivingLicenseDeputyMsg = res.data.uploadDrivingLicenseDeputyMsg;
				}
			},
			// 挂车行驶证正面
			async afterPictureImg(event) {
				let api = `${this.baseUrl}/driverService/upload_driving_license`
				let lists = [].concat(event.file)
				this[`file${event.name}`].push({
					...event.file,
					status: 'uploading',
					message: '上传中'
				})
				const result = await this.uploadFilePromise(lists[0].thumb, api)
				const res = JSON.parse(result)
				console.log(res)
				if (res.code != 0) {
					uni.$u.toast(res.msg)
					this[`file${event.name}`] = []
				} else {
					this.showData = res.data
					if(res.data.isTractor != '2'){
						this.showModal1 = true
						this.contentModal1 = '检测到上传证据为行驶证照片，是否填充为行驶证信息'
						this.showData.dataType = 1
						return false
					}
					this[`file${event.name}`].splice(0, 1, Object.assign(this[`file${event.name}`][0], {
						status: 'success',
						message: '上传成功',
						url: res.data.imgurl
					}))
					this.trailerInfo.pictureImg = res.data.imgurl
					this.trailerInfo.plateNum = res.data.plateNum
					this.trailerInfo.plateNumOcr = res.data.plateNum
					this.trailerInfo.vehicleColour = res.data.vehicleColour
					this.trailerInfo.vanType = res.data.vanType
					this.trailerInfo.validPeriod = res.data.validPeriod
					this.trailerInfo.axle = res.data.axle
					this.trailerInfo.natureUse = res.data.natureUse
					this.trailerInfo.owner = res.data.owner
					this.trailerInfo.vehicleEnergyType = res.data.vehicleEnergyType
					this.trailerInfo.issuingOrganizations = res.data.issuingOrganizations
					this.trailerInfo.registerDate = res.data.registerDate
					this.trailerInfo.vin = res.data.vin
					this.trailerInfo.vehicleBrand = res.data.vehicleBrand
					this.trailerInfo.fileNo = res.data.fileNo
					this.trailerInfo.issueDate = res.data.issueDate
					this.trailerInfo.isTractorOrc = res.data.isTractor
					this.trailerInfo.pictureImgFlag = '0'
					// this.trailerInfo.pictureImgDeputyFlag = '0'
					// "pictureImg": "https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/b9b09e7dfd4342ec9d6118de03a219a5.jpg", //挂车图片正
					// "pictureImgDeputy": "https://y2t-nfp-dev-1258746579.cos.ap-guangzhou.myqcloud.com/5500bb0fd5ac4440b116457f0d2eca20.jpg", //挂车图片副
					// "plateNum": "赣C3E872", //车牌号
					// "plateNumOcr": "赣C3E872", //车牌号OCR识别
					// "plateColour": "1", //车牌颜色
					// "vehicleColour": "", //车辆颜色
					// "vanType": "", //车辆类型
					// "validPeriod": "2031-02-03T16:00:00.000Z", //挂车有效期
					// "axle": "", //车轴
					// "length": "11", //车长
					// "width": "", //车宽
					// "high": "", //车高
					// "natureUse": "222", //使用性质
					// "owner": "111", //所有人
					// "vehicleEnergyType": "333", //车辆能源
					// "issuingOrganizations": "444", //发证机关
					// "registerDate": "2023-02-01", //注册日期
					// "vin": "555", //车辆识别代号
					// "issueDate": "2023-02-01", //发证日期
					// "vehicleBrand": "", //车辆品牌
					// "fileNo": "", //行驶证档案编号
					// "pictureImgFlag": 0, //挂车图片是否异常 0.正常 1.异常
					// "pictureImgDeputyFlag": 0 //挂车副图片是否异常 0.正常 1.异常
				}
			},
			// 挂车行驶证反面
			async afterPictureImgDeputy(event) {
				let api = `${this.baseUrl}/driverService/upload_driving_license_deputy`
				let lists = [].concat(event.file)
				this[`file${event.name}`].push({
					...event.file,
					status: 'uploading',
					message: '上传中'
				})
				const result = await this.uploadFilePromise(lists[0].thumb, api)
				const res = JSON.parse(result)
				console.log(res)
				if (res.code != 0) {
					uni.$u.toast(res.msg)
					this[`file${event.name}`] = []
				} else {
					this[`file${event.name}`].splice(0, 1, Object.assign(this[`file${event.name}`][0], {
						status: 'success',
						message: '上传成功',
						url: res.data.imgurl
					}))
					this.trailerInfo.pictureImgDeputy = res.data.imgurl
					this.trailerInfo.plateNumDeputyOcr = res.data.plateNumOcrDrivingPermit
					this.trailerInfo.validPeriod = res.data.validPeriod
					this.trailerInfo.validPeriodOcr = res.data.validPeriod
					this.trailerInfo.length = res.data.length
					this.trailerInfo.width = res.data.width
					this.trailerInfo.high = res.data.high
					this.trailerInfo.pictureImgDeputyFlag = '0'
				}
			},
			// 道路运输证正面
			async afterReadRtc(event) {
				let api = `${this.baseUrl}/driverService/uploadRtc`
				let lists = [].concat(event.file)
				this[`file${event.name}`].push({
					...event.file,
					status: 'uploading',
					message: '上传中'
				})
				const result = await this.uploadFilePromise(lists[0].thumb, api)
				const res = JSON.parse(result)
				console.log(res)
				if (res.code != 0) {
					uni.$u.toast(res.msg)
					this[`file${event.name}`] = []
				} else {
					this[`file${event.name}`].splice(0, 1, Object.assign(this[`file${event.name}`][0], {
						status: 'success',
						message: '上传成功',
						url: res.data.imgurl
					}))
					this.license.rtc = res.data.imgurl;
					this.license._rtcNo = res.data.rtcNo;
					this.license.rtcNo = res.data.rtcNo;
					this.license.uploadRtcFlag = res.data.uploadRtcFlag;
					this.license.uploadRtcMsg = res.data.uploadRtcMsg;
				}
			},
			// 从业资格证正面
			async afterReadTqc(event) {
				let api = `${this.baseUrl}/driverService/uploadTqc`
				let lists = [].concat(event.file)
				this[`file${event.name}`].push({
					...event.file,
					status: 'uploading',
					message: '上传中'
				})
				const result = await this.uploadFilePromise(lists[0].thumb, api)
				const res = JSON.parse(result)
				// console.log(res)
				if (res.code != 0) {
					uni.$u.toast(res.msg)
					this[`file${event.name}`] = []
				} else {
					this[`file${event.name}`].splice(0, 1, Object.assign(this[`file${event.name}`][0], {
						status: 'success',
						message: '上传成功',
						url: res.data.imgurl
					}))
					this.license.tqc = res.data.imgurl;
					this.license.tqcNo = res.data.tqcNo;
				}
			},
			// 新增图片
			async afterRead(event) {
				// console.log(event)
				let lists = [].concat(event.file)
				this[`file${event.name}`].push({
					...event.file,
					status: 'uploading',
					message: '上传中'
				})
				const result = await this.uploadFilePromise(lists[0].thumb)
				const res = JSON.parse(result)
				if (res.code != 0) {
					uni.$u.toast(res.msg)
					this[`file${event.name}`] = []
				} else {
					this[`file${event.name}`].splice(0, 1, Object.assign(this[`file${event.name}`][0], {
						status: 'success',
						message: '上传成功',
						url: res.data
					}))
				}
			},
			uploadFilePromise(url, api) {
				return new Promise((resolve, reject) => {
					let upload = uni.uploadFile({
						url: api ? api : `${this.baseUrl}/driverService/upload`,
						filePath: url,
						name: 'file',
						header: {
							Authorization: Cache.get("TOKEN")
						},
						formData: {
							fileType: '2',
							mobile: Cache.get("USERINFO").mobile,
							fileId: Math.floor(Math.random() * 1259),
							ocrOrNot: '1',
							orderId: ''
						},
						success: res => {
							setTimeout(() => {
								resolve(res.data)
							}, 800)
						},
						fail: err => {
							reject(err)
						}
					});
				})
			},
			//	新增车辆
			postRegister() {
				if(!this.license.plateNum){
					this.license.plateNum = this.license._plateNum
				}
				
				let data = Object.assign(this.license, {
					plateColour: this.colorValue,
					vehicleNature: this.typeValue,
					manualPlateNum: this.license._plateNum
				})
				this.license.isTractor = this.typeTrailerValueCache
				if(this.license.isTractor){
					this.license.trailerInfo = this.trailerInfo
					this.license.trailerInfo.pictureImgFlag =  this.trailerInfo.isTractorOrc !=2?1:0
				}
				console.log(data,'传入的参数')
				let parmas = {
					"vehicleInfoUnified": data,
					"dataSources": 2, //数据来源 0.PC 1.司机端 2.货主端
					"etpId": this.license.etpId, //企业id（当数据来源为1.司机端时为必传字段）
					"driverId": this.license.driverId,
					"tqc": this.license.tqc,
					"tqcDeputy": this.license.tqcDeputy,
					"tqcNo": this.license.tqcNo
				}
				console.log(params,'传入的车辆参数')
				return false
				driverRelVehicle(data).then(res => {
					console.log(res,'新增')
					if (res.code != 0) {
						uni.$u.toast(res.msg);
					} else {
						uni.$u.toast("提交成功");
						setTimeout(() => {
							uni.navigateBack()
						}, 600)
					}
				}).catch(err => {
					console.log(err)
				})
			},
			//	编辑司机
			postUpdate() {
				this.showModal = false
				let data = Object.assign(this.license, {
					plateColour: this.colorValue,
					vehicleNature: this.typeValue,
					vehicleId: this.vehicleId,
					isTractor: this.typeTrailerValueCache,
				})
				this.license.isTractor = this.typeTrailerValueCache
				if(this.license.isTractor){
					this.license.trailerInfo = this.trailerInfo
				}
				console.log(data,1111)
				editVehicle(data).then(res => {
					console.log(res)
					if (res.code != 0) {
						uni.$u.toast(res.msg);
					} else {
						uni.$u.toast("提交成功");
						setTimeout(() => {
							uni.navigateTo({
								url: '/pages/vehicle/index'
							})
						}, 600)
					}
				}).catch(err => {
					console.log(err)
				})
			},
			//	车辆提交
			confirm() {
				this.showModal = false
				this.type === 1 ? this.postUpdate() : this.postRegister()
			},
			//	提交
			submit() {
				if (this.fileRtcDeputy.length) {
					this.license.rtcDeputy = this.fileRtcDeputy[0].url
				}
				if (this.fileTqcDeputy.length) {
					this.llicense.tqcDeputy = this.fileTqcDeputy[0].url
				}
				const {
					drivingLicense,
					vehicleLicenseDeputy,
					_plateNum,
					plateNum,
					plateNumOcrDrivingPermit,
					validPeriod,
					weightFlag,
					rtc,
					rtcDeputy,
					_rtcNo,
					uploadDrivingLicenseFlag,
					uploadDrivingLicenseMsg,
					uploadDrivingLicenseDeputyFlag,
					uploadDrivingLicenseDeputyMsg,
				} = this.license
				
				
				// this.license.emissionStandard = this.emissionStandardvalue
				if (!this.fileLicense.length) {
					uni.$u.toast('请上传行驶证正页！');
					return
				}
				if (!this.fileLicenseDeputy.length) {
					uni.$u.toast('请上传行驶证副页！');
					return
				}
				if (!_plateNum) {
					uni.$u.toast('请输入车牌号！');
					return
				}
				if (!this.typeValue) {
					uni.$u.toast('请完善车辆性质！');
					return
				}
				if (!this.colorValue) {
					uni.$u.toast('请完善车牌颜色！');
					return
				}
				// if (!this.license.emissionStandard) {
				// 	uni.$u.toast('请完善排放标准！');
				// 	return
				// }
				if (!_plateNum || _plateNum.length != 7 && _plateNum.length != 8) {
					uni.$u.toast('请输入有效的车牌号！');
					return
				}

				if (weightFlag) {
					if (!rtc || !rtcDeputy) {
						uni.$u.toast('上传道路运输证！');
						return
					}
					if (!_rtcNo) {
						uni.$u.toast('请输入道路运输证号！');
						return
					}
					if (_rtcNo.length < 5 || _rtcNo.length > 15) {
						uni.$u.toast('请输入有效的道路运输证号！');
						return
					}
				}
				
				if(this.typeTrailerValueCache){
					if (!this.trailerInfo.pictureImg) {
						uni.$u.toast('请上传挂车正面行驶证！');
						return
					}
					if (!this.trailerInfo.pictureImgDeputy) {
						uni.$u.toast('请上传挂车副页行驶证！');
						return
					}
					if (!this.trailerInfo.plateNum) {
						uni.$u.toast('请输入有效的挂车行驶证号！');
						return
					}
					if (!this.trailerInfo.validPeriod) {
						uni.$u.toast('请输入有效的挂车行驶证强制报废日期！');
						return
					}
					if (!this.trailerInfo.plateNum || this.trailerInfo.plateNum.length != 7 && this.trailerInfo.plateNum.length != 8) {
						uni.$u.toast('请输入有效的挂车车牌号！');
						return
					}
				}
				if(this.license.isTractorOrc == 2){
					this.contentModal = '检测到您传行驶证为挂车行驶证，是否继续提交'
					this.license.uploadDrivingLicenseDeputyFlag = 1
					this.license.uploadDrivingLicenseDeputyMsg = '行驶证照片为挂车行驶证，请重新修改后再提交'
					this.showModal = true
					// this.license.uploadDrivingLicenseMsg = 1
					return
					
				}
				if (Date.parse(validPeriod) + 24*60*60*1000 < new Date().getTime()) {
					this.contentModal = '您提交的行驶证已过期，请重新修改后再提交'
					this.license.uploadDrivingLicenseDeputyFlag = 1
					this.license.uploadDrivingLicenseDeputyMsg = '行驶证强制报废期小于当前时间，请重新修改后再提交'
					this.showModal = true
					return
				}
				
				if (uploadDrivingLicenseFlag == 1 || uploadDrivingLicenseDeputyFlag == 1) {
					this.contentModal = '您提交的行驶证照片疑似非有效证件，请重新修改后再提交1'
					this.showModal = true
					return
				}
				
				if (_plateNum != plateNum || _plateNum != plateNumOcrDrivingPermit) {
					this.contentModal = '您提交的行驶证车牌号和证件不一致，请重新修改后再提交'
					this.license.uploadDrivingLicenseFlag = 1
					this.license.uploadDrivingLicenseMsg = '提交的车牌号和证件不一致，请重新修改后再提交'
					this.showModal = true
					return
				}
				
			
				if (!validPeriod) {
					this.contentModal = '您提交的行驶证照片疑似非有效证件，请重新修改后再提交'
					this.license.uploadDrivingLicenseDeputyFlag = 1
					this.license.uploadDrivingLicenseDeputyMsg = '行驶证强制报废期不存在，请重新修改后再提交'
					this.showModal = true
					return
				}
				
				if(this.typeTrailerValueCache){
					if (this.trailerInfo.plateNumDeputyOcr != this.trailerInfo.plateNum || this.trailerInfo.plateNum != this.trailerInfo.plateNumOcr) { //ocr识别挂车，选择非挂车
						this.contentModal = '您提交的挂车车牌号和证件不一致，请重新修改后再提交'
						this.trailerInfo.pictureImgFlag = 1
						this.trailerInfo.pictureImgDeputyMsg = '提交的挂车车牌号和证件不一致，请重新修改后再提交'
						this.showModal = true
						return
					}
					if (Date.parse(this.trailerInfo.validPeriod) + 24*60*60*1000 < new Date().getTime()) {
						this.contentModal = '您提交的挂车行驶证已过期，请重新修改后再提交'
						this.trailerInfo.pictureImgDeputyFlag = 1
						this.trailerInfo.pictureImgDeputyMsg = '挂车行驶证强制报废期小于当前时间，请重新修改后再提交'
						this.showModal = true
						return
					}
					if (!this.trailerInfo.validPeriod) {
						this.contentModal = '您提交的挂车行驶证照片疑似非有效证件，请重新修改后再提交'
						this.trailerInfo.pictureImgDeputyFlag = 1
						this.trailerInfo.pictureImgDeputyMsg = '挂车行驶证强制报废期不存在，请重新修改后再提交'
						this.showModal = true
						return
					}
					
				}
				this.confirm()
			},
			//	字典查询: 车轴 AXLE / 车牌颜色 PLATE_COLOR / 车辆颜色 VEHICLE_COLOUR / 车辆性质 VEHICLE_NATURE / 车辆类型 VAN_TYPE TRACTOR_TYPE
			getQueryDic() {
				queryDic(['VAN_TYPE', 'TRACTOR_TYPE', 'PLATE_COLOR', 'VEHICLE_COLOUR', 'VEHICLE_NATURE', 'AXLE'], {
					custom: {
						title: '字典查询中……'
					}
				}).then(res => {
					// console.log(res)
					if (res.code != 0) {
						uni.$u.toast(res.msg);
					} else {
						this.typeColumns = res.data.VEHICLE_NATURE
						this.colorColumns = res.data.PLATE_COLOR
						this.typeNameCache = this.typeColumns[0].dicName
						this.typeValueCache = this.typeColumns[0].dicValue
						this.colorNameCache = this.colorColumns[0].dicName
						this.colorValueCache = this.colorColumns[0].dicValue
					}
				}).catch(err => {
					console.log(err)
				})
			},
			setPlate(plate) {
				if (plate.length >= 7) this.license._plateNum = plate
				this.showCar = false
			},
			onPlate() {
				if (!this.fileLicense.length) {
					return
				}
				this.showCar = true
			},
			onPlate1() {
				if (!this.filePictureImg.length) {
					return
				}
				this.showCar1 = true
			},
			setPlate1(plate) {
				if (plate.length >= 7) this.trailerInfo.plateNum = plate
				this.showCar1 = false
			},
			trailerConfirm(){
				this.showTrailer = false
				this.typeTrailerValueCache =  this.typeTrailerNameCache
				this.license.typeTrailerValue = this.typeTrailerNameCache
				this.typeTrailerValue = this.typeTrailerNameCache?'是':'否'
				// console.log(this.license.typeTrailerValue,'-----',this.typeTrailerValue)
			},
			trailerChange(value){
				this.typeTrailerNameCache =  value.val
			},
			trailerCancel(){
				this.showTrailer = false
				this.typeTrailerValueCache = this.typeTrailerValue == '是'?1:0
				this.license.typeTrailerValue = this.typeTrailerValueCache
				this.typeTrailerNameCache = this.typeTrailerValue == '是'?1:0
				// console.log(this.license.typeTrailerValue,'-----',this.typeTrailerValue)
			},
			typeConfirm() {
				this.showType = false
				this.typeName = this.typeNameCache
				this.typeValue = this.typeValueCache
			},
			typeCancel() {
				this.showType = false
				if (this.typeValue) {
					this.typeNameCache = this.typeName
					this.typeValueCache = this.typeValue
				} else {
					this.typeNameCache = this.typeColumns[0].dicName
					this.typeValueCache = this.typeColumns[0].dicValue
				}
			},
			typeChange(item) {
				this.typeNameCache = item.dicName
				this.typeValueCache = item.dicValue
			},
			//排放标准选择
			emissionCancel(){
				this.showEmissionStandar = false
			},
			emissionChange(item){
				this.emissionStandardCache = item.dicName
				this.emissionStandardvalue = item.val
			},
			emissionConfirm(){
				this.showEmissionStandar = false
				this.emissionStandardName = this.emissionStandardCache
				this.license.emissionStandard = this.emissionStandardvalue?this.emissionStandardvalue:1
				console.log(this.license.emissionStandard)
			},
			//选择强制报废期
			validPeriodConfirm(value){
				// console.log(value.value)
				this.license.validPeriod = this.formatDate(value.value)
				this.validPeriodTime = this.validPeriod
				this.showValidPeriod = false
			},
			validPeriodConfirm1(value){
				// console.log(value.value)
				this.trailerInfo.validPeriod = this.formatDate(value.value)
				this.validPeriodTime1 = this.validPeriod1
				this.showValidPeriod1 = false
			},
			//车牌颜色选择
			colorConfirm() {
				this.showColor = false
				this.colorValue = this.colorValueCache
				this.colorName = this.colorNameCache
			},
			colorCancel() {
				this.showColor = false
				if (this.colorValue) {
					this.colorValueCache = this.colorValue
					this.colorNameCache = this.colorName
				} else {
					this.colorNameCache = this.colorColumns[0].dicName
					this.colorValueCache = this.colorColumns[0].dicValue
				}
			},
			colorChange(item) {
				this.colorValueCache = item.dicValue
				this.colorNameCache = item.dicName
			},
			setClass(num) {
				return num > 2 ? 'third' : 'second'
			},
			formatDate(date) { 
				var now = new Date(parseInt(date))
				let y = now.getFullYear()
				let m = now.getMonth() + 1
				let d = now.getDate()
				return y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d)
			},
		},
		components: {
			plateInput
		}
	}
</script>

<style lang="scss">
	page {
		background: #fafafa;
		width: 100vw;
		height: 100vh;
		box-sizing: border-box;
	}

	.popup-wrap {
		padding: 32rpx;

		.title {
			text-align: center;
			font-size: 32rpx;
			font-weight: 500;
			color: #333333;
			margin-bottom: 24rpx;
		}

		.popup-btn {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 12rpx 0 calc(12rpx + env(safe-area-inset-bottom));

			.btn {
				font-size: 30rpx;
				font-weight: 500;
				line-height: 80rpx;
				border-radius: 12rpx;
				text-align: center;
				box-shadow: 0 0 20rpx 12rpx rgba(0, 62, 129, 0.04);
				box-sizing: border-box;
			}

			.cancel {
				color: #333333;
				width: 40%;
				background: #fff;
				border: 1rpx solid #e9e9e9;
			}

			.confirm {
				width: 55%;
				color: #FFFFFF;
				background: linear-gradient(to right, #4d83b9, #003E81);
			}
		}

		.popup-list {
			box-sizing: border-box;
			margin: 48rpx 0 12rpx;
			font-size: 30rpx;
			font-weight: 500;
			color: #333333;

			text {
				display: flex;
				align-items: center;
				justify-content: center;
				padding: 24rpx 0;
				background: #FAFAFA;
				border-radius: 4rpx;
				margin-bottom: 32rpx;

				&.active {
					background: #F0F7FF;
				}
			}

			.third {
				display: flex;
				align-items: center;
				flex-wrap: wrap;

				text {
					width: 30%;

					&:nth-child(3n-1) {
						margin-right: 5%;
						margin-left: 5%;
					}
				}
			}

			.second {
				display: flex;
				justify-content: space-between;
				align-items: center;
				width: 100%;

				text {
					width: 45%;
				}
			}
		}
	}

	.wrap {
		width: 100vw;
		height: 100vh;
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		box-sizing: border-box;
	}

	.content {
		width: 100%;
		overflow: auto;
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		bottom: calc(90rpx + env(safe-area-inset-bottom));
	}

	.item {
		padding-top: 20rpx;
		background: #fff;
		margin: 18rpx 0;

		.tips {
			font-size: 26rpx;
			font-weight: 400;
			color: #9E9E9E;
			line-height: 36rpx;
			padding-bottom: 24rpx;
		}

		.title {
			padding-left: 24rpx;
			border-left: 8rpx solid #003E81;
			font-size: 34rpx;
			font-weight: 500;
			color: #333;
		}

		.info-wrap {
			padding: 24rpx 32rpx 0;
		}

		.upload-box {
			display: flex;
			justify-content: space-between;
			align-items: center;

			.upload-item {
				width: 50%;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;

				.u-upload__wrap__preview {
					margin: 0 !important;
				}

				.desc {
					font-size: 24rpx;
					font-weight: 400;
					line-height: 2;
					color: #666;
					margin-top: 12rpx;
				}
			}
		}
	}

	.bottom-wrap {
		position: absolute;
		left: 0;
		bottom: calc(10rpx + env(safe-area-inset-bottom));
		width: 100vw;
		padding: 0 32rpx;
		box-sizing: border-box;

		.submit {
			width: 100%;
			font-size: 30rpx;
			font-weight: 500;
			color: #FFFFFF;
			line-height: 80rpx;
			border-radius: 12rpx;
			text-align: center;
			background: linear-gradient(to right, #4d83b9, #003E81);
		}
	}
</style>
